<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <!--[if lt IE 9]>
    <script type="text/javascript" src="lib/html5shiv.js"></script>
    <script type="text/javascript" src="lib/respond.min.js"></script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="lib/Hui-iconfont/1.0.8/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/style.css" />
    <link rel="stylesheet" href="lib/zTree/v3/css/zTreeStyle/zTreeStyle.css" type="text/css">
    <!--[if IE 6]>
    <script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <title>回收列表</title>
</head>
<style>
    .table>tbody>tr>td{
        text-align:center;
    }
</style>
<body>
<div style="padding:2vw">
    <table class="table table-border table-bordered table-bg table-hover table-sort" width="100%">
        <thead>
        <tr class="text-c">
            <th width="50">ID</th>
            <th width="100">冰包编码</th>
            <th width="50">回收时间</th>
            <th width="100">操作</th>
        </tr>
        </thead>
    </table>
</div>
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="static/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="lib/common.js"></script>
<script type="text/javascript">

    var bindId = parent.bindId
    /*datatables配置*/
    var table =  $('.table').DataTable({
        serverSide: true,//开启服务器模式
        "processing": true,//加载显示提示
        "ajax": {
            url:"./box/recycle/list",
            type: 'GET',
            data:{
                "bindId":bindId
            },
        },
        "columns": [

            { "data": "id"},
            { "data": "boxCode"},
            { "data": "createTime",
                render : function(data,type, row, meta) {
                    return date(data);
                }
            },
            {
                "data": null,
                render: function (data, type, row, meta) {
                    return "<input onclick='del()' class='btn btn-danger-outline size-S radius' type='button' value='删除'>";
                }
            }
        ],
        "aaSorting": [[ 1, "desc" ]],//默认第几个排序
        "bStateSave": false,//状态保存
        "aoColumnDefs": [
            {"orderable":false,"aTargets":[0]}// 制定列不参与排序
        ],
        language: {
            url: './lib/datatables/Chinese.json'
        },
        colReorder: true
    });


    function del(){
        $('.table tbody').on( 'click', 'tr', function () {
            var id = table.row( this ).data().id;
            layer.confirm('确认要删除ID为\''+id+'\'的记录吗？',{icon:0},function(){
                var index = layer.load(3);
                $.ajax({
                    type: 'DELETE',
                    url: './box/recycle/delete/'+id,
                    dataType: 'json',
                    success: function(data){
                        layer.close(index);
                        if(data.success!=true){
                            layer.alert(data.message,{title: '错误信息',icon: 2});
                            return;
                        }
                        refresh();
                        layer.msg('已删除!',{icon:1,time:1000});
                    },
                    error:function(XMLHttpRequest) {
                        layer.close(index);
                        layer.alert('数据处理失败! 错误码:'+XMLHttpRequest.status,{title: '错误信息',icon: 2});
                    },
                });
            });
        });
    }
</script>
</body>
</html>
